# -*- coding:utf-8 -*-
import logging

import allure

from Python_Calculator.PO.base_page import BasePage


class GetCal(BasePage):
    def add_way(self, a, b):
        """
        加法计算
        """
        logging.info("开始计算")
        with allure.step("加法计算"):
            result= self.add(a, b)
        if isinstance(result,float):
            result=round(result,2) # 如果结果是float浮点数型用round保留2位小数
        logging.info(f'{a}+{b}等于{result}')  # 打印日志
        logging.info("结束计算")
        return result

    def sub_way(self, a, b):
        """
        减法计算
        """
        with allure.step("减法计算"):
            result= self.sub(a, b)
        logging.info(f'{a}-{b}等于{result}')  # 打印日志
        return result

    def mul_way(self, a, b):
        """
        乘法计算
        """
        with allure.step("乘法计算"):
            result= self.mul(a, b)
        logging.info(f'{a}乘{b}等于{result}')  # 打印日志
        return result

    def div_way(self, a, b):
        """
        除法计算
        """
        with allure.step("除法计算"):
            result = self.div(a, b)
            if isinstance(result, float):
                result = round(result, 2)  # 如果结果是float浮点数型用round保留2位小数
        logging.info(f'{a}除{b}等于{result}')  # 打印日志
        return result